﻿@page "/product"
@inherits ProductListBase
@using ClassifiedAds.Blazor.Components

<h1>Product List</h1>

@if (Products == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <table class="table">
        <thead>
            <tr>
                <th>Code</th>
                <th>Name</th>
                <th>Description</th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            @foreach (var product in Products)
            {
                <tr>
                    <td>@product.Code</td>
                    <td>@product.Name</td>
                    <td>@product.Description</td>
                    <td>
                        <button @onclick="@(()=> EditProduct(product))" class="btn btn-dark"><span class="oi oi-pencil"></span></button>
                        <button @onclick="@(()=> DeleteProduct(product))" class="btn btn-dark"><span class="oi oi-circle-x"></span></button>
                    </td>
                </tr>
            }
        </tbody>
    </table>
}

<button @onclick="@QuickAddProduct" class="btn btn-dark table-btn quick-add-btn"><span class="oi oi-plus"></span></button>

<AddProductDialog @ref="AddProductDialog" CloseEventCallback="@AddProductDialog_OnDialogClose"></AddProductDialog>
<DeleteProductDialog @ref="DeleteProductDialog" CloseEventCallback="@DeleteProductDialog_OnDialogClose"></DeleteProductDialog>
